Nitrogen fixation
Although the bulk of the plant material is made of carbon, which is taken from the air-in the form of CO2, there are many other elements needed for a plant to grow. The elements taken from the soil in large quantities are N, P K. These are often added to the soil in the form of fertilizers.
Those elements can also originate on decaying plant material that is found on soil: leaves, stems, etc. These are attacked by fungi and bacteria (decomposers) so that the nitrogen and other elements are available to be uptaken by plants. It is a cycle. Like the water cycle, the nitrogen cycle is very important.
Legumes –like beans, peas, lentils etc - have lots of proteins. They are the main source of proteins available to vegetarian people. Proteins are formed of carbon, oxygen, hydrogen, nitrogen and, some of them, sulfur.
The legumes can afford to produce so much protein because it has a source of nitrogen in its roots. There are bacteria ( Rhizobium), which acumulate in the roots of the luguminosae forming nodules, which fixate nitrogen from the air.
They have special enzymes that are needed to break the triple bond in the nitrogen molecule (which is a very strong chemical bond), in order to make the nitrogen atoms available to form ammonia and nitrates, which are nitrogen containing substances that can be uptaken by plants and incorporated into their proteins.
The bacteria also benefits from being in the roots of the plant.
Ricardo Oliveira 2006
“So, nitrogen is often the limiting factor for growth and biomass production in all environments where there is suitable climate and availability of water to support life”. Extracted from: http://helios.bto.ed.ac.uk/bto/microbes/nitrogen.htm